package com.macro.mall.portal.service.impl;

import cn.hutool.core.date.DateTime;
import com.macro.mall.mapper.BmsSightseeingBusApplicantMapper;
import com.macro.mall.mapper.BmsSightseeingBusMapper;
import com.macro.mall.mapper.BmsSightseeingBusPicMapper;
import com.macro.mall.mapper.BmsSightseeingBusPointMapper;
import com.macro.mall.model.BmsSightseeingBus;
import com.macro.mall.model.BmsSightseeingBusApplicant;
import com.macro.mall.model.BmsSightseeingBusPic;
import com.macro.mall.model.UmsMember;
import com.macro.mall.portal.dto.BmsSightseeingBusParam;
import com.macro.mall.portal.service.BmsSightseeingBusApplicantService;
import com.macro.mall.portal.service.BmsSightseeingBusService;
import com.macro.mall.portal.util.MemberUtil;
import com.macro.mall.portal.util.MemberUtils;
import com.macro.mall.portal.util.UserUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;


/**
 * 商品属性管理Service实现类
 * Created by macro on 2018/4/26.
 */
@Service
public class BmsSightseeingBusServiceImpl implements BmsSightseeingBusService {
    @Autowired
    private BmsSightseeingBusMapper bmsSightseeingBusMapper;
    @Autowired
    private UserUtils userUtils;

    @Autowired
    private BmsSightseeingBusPicMapper bmsSightseeingBusPicMapper;
    @Autowired
    private  BmsSightseeingBusPointMapper bmsSightseeingBusPointMapper;

    @Autowired
    private MemberUtil memberUtil;

    @Autowired
    private BmsSightseeingBusApplicantMapper bmsSightseeingBusApplicantMapper;


    /**
     * 小程序查询观光车
     * @return
     */
    @Transactional
    @Override
    public List<BmsSightseeingBus> getMpList() {
        List<BmsSightseeingBus> list = bmsSightseeingBusMapper.selectXiaochengxu();
        return list;
    }


    @Override
    public BmsSightseeingBus getBusDetail(BmsSightseeingBus bmsSightseeingBus){
        return bmsSightseeingBusMapper.getBusDetail(bmsSightseeingBus);
    }


    /**
     * 获取单个观光车信息
     */
    @Override
    public List<BmsSightseeingBusApplicant> getMpDetail(BmsSightseeingBusParam sightseeingBusParam) {
         UmsMember umsMember = MemberUtils.getUser();
        List<BmsSightseeingBus> bmsSightseeingBusList = new ArrayList<>();
        //重新定义一个
        BmsSightseeingBusApplicant bmsSightseeingBusApplicant = new BmsSightseeingBusApplicant();
        bmsSightseeingBusApplicant.setSightseeingBusId(sightseeingBusParam.getId());
        //需要最后替换成umsMember参数
        bmsSightseeingBusApplicant.setUserId(umsMember.getId());
        List<BmsSightseeingBusApplicant> bmsSightseeingBusApplicants = bmsSightseeingBusApplicantMapper.selectApplicant(bmsSightseeingBusApplicant);
        return bmsSightseeingBusApplicants;
    }
}
